package com.example.demoplus.ui.order;

import androidx.lifecycle.ViewModelProvider;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.demoplus.MainActivity;
import com.example.demoplus.R;

public class SettingFragment extends Fragment implements View.OnClickListener{
    private RelativeLayout rlTitleBar;
    private TextView tvTitle;
    private ImageView ivBack;
    public static SettingFragment newInstance() {
        return new SettingFragment();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.setting_fragment, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView(view);
    }

    @Override
    public void onClick(View v) {
        toOrderActivity();
    }
    private void toOrderActivity() {
        Intent intent = new Intent(getContext(), MainActivity.class);
        startActivity(intent);
    }
    private void initView(View view) {
        rlTitleBar = view.findViewById(R.id.rl_title_bar);
        tvTitle = view.findViewById(R.id.tv_title);
        ivBack = view.findViewById(R.id.iv_back);
        tvTitle.setText("设置");
//        显示返回按钮可见
        ivBack.setVisibility(View.VISIBLE);
        ivBack.setOnClickListener(this);
    }
}